package com.qf.springwork.entity;

import cn.hutool.core.util.RandomUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {

    private Integer id;
    private String name;
    private String password;
    private String sex;
    private Date birthday;
    private Date registTime;
    private String auth;
    private String status;
    private Integer amount;

    public static User randomUser(){
        User user = new User();
        String name = RandomUtil.randomString(8);
        String password = RandomUtil.randomString(6);
        user.setName(name);
        user.setPassword(password);
        return user;
    }

    public static List<User> randomUsers(Integer size){
        List<User> users = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            users.add(randomUser());
        }
        return users;
    }

    public String toCSVString(){
        return this.name+","+this.password;
    }
}
